<template>
  <div class="group-table-box">

    <el-row class="group-top">
      <el-col :span="8" :offset="16" class="group-right">
        <div class="input-item" style="margin: 0;">
          <el-button
            type="primary"
            size="small"
            @click="onClickAddAccount"
          >添加账号信息</el-button>
        </div>
      </el-col>
    </el-row>

    <div class="table-container">
      <el-table
        :data="tableData"
        border
        :header-cell-class-name="'table-header'"
      >
        <el-table-column
          type="index"
          label="序号"
          align="center"
          width="80">
        </el-table-column>
        <el-table-column
          prop="name"
          label="登录名"
          align="center">
        </el-table-column>
        <el-table-column
          prop="address"
          align="center"
          label="权限">
        </el-table-column>
        <el-table-column
          prop="address"
          align="center"
          label="账号名称 ">
        </el-table-column>
        <el-table-column
          prop="name"
          label="创建时间"
          align="center">
        </el-table-column>
        <el-table-column
          prop="address"
          align="center"
          label="最后登录时间">
        </el-table-column>
        <el-table-column
          align="center"
          label="操作"
          width="250px"
        >
          <template slot-scope="scope">
            <el-button
              size="mini"
              type="primary"
              @click="edit(scope.$index, scope.row)"
            >编辑</el-button>
            <el-button
              size="mini"
              type="danger"
              @click="remove(scope.$index, scope.row)"
            >删除</el-button>
            <el-button
              size="mini"
              type="warning"
              @click="resetPassword(scope.$index, scope.row)"
            >重置密码</el-button>
          </template>
        </el-table-column>
      </el-table>
      <el-pagination
        :current-page.sync="form.pageIndex"
        :page-size="100"
        layout="total, prev, pager, next"
        :total="totalPageCount"
        style="text-align: center;margin-top: 20px;"
      >
      </el-pagination>
    </div>

    <!-- 点击编辑 -->
    <el-dialog
      :visible.sync="showEditModal"
    >
      <div class="modal-container">
        <div class="modal-label">
          <span>账号信息</span>
        </div>
        <el-row class="modal-content" :gutter="16">
          <el-col :span="4">
            <p class="modal-label-detail">账号登录名</p>
          </el-col>
          <el-col :span="20">
            <el-input
              v-model="form.remark"
              placeholder="请输入..."
              size="small"
            ></el-input>
          </el-col>
        </el-row>
        <el-row class="modal-content" :gutter="16">
          <el-col :span="4">
            <p class="modal-label-detail">账号名称</p>
          </el-col>
          <el-col :span="20">
            <el-input
              v-model="form.remark"
              placeholder="请输入..."
              size="small"
            ></el-input>
          </el-col>
        </el-row>
        <el-row class="modal-content" :gutter="16">
          <el-col :span="4">
            <p class="modal-label-detail">初始密码</p>
          </el-col>
          <el-col :span="20">
            <el-input
              v-model="form.remark"
              placeholder="请输入..."
              size="small"
            ></el-input>
          </el-col>
        </el-row>
        <el-row class="modal-content" :gutter="16">
          <el-col :span="4">
            <p class="modal-label-detail">账号权限</p>
          </el-col>
          <el-col :span="20">
            <el-select v-model="form.class" placeholder="请选择" size="small">
              <el-option value="撒钱活动">撒钱活动</el-option>
              <el-option value="VIP活动">VIP活动</el-option>
            </el-select>
          </el-col>
        </el-row>
        <div slot="footer" class="modal-footer">
          <el-button
            type="primary"
            size="small"
            @click="onClickEditConfirm"
          >完成</el-button >
        </div>
      </div>
    </el-dialog>

    <!-- 点击添加 -->
    <el-dialog
      :visible.sync="showAddModal"
    >
      <div class="modal-container">
        <div class="modal-label">
          <span>账号信息</span>
        </div>
        <el-row class="modal-content" :gutter="16">
          <el-col :span="4">
            <p class="modal-label-detail">账号登录名</p>
          </el-col>
          <el-col :span="20">
            <el-input
              v-model="form.remark"
              placeholder="请输入..."
              size="small"
            ></el-input>
          </el-col>
        </el-row>
        <el-row class="modal-content" :gutter="16">
          <el-col :span="4">
            <p class="modal-label-detail">账号名称</p>
          </el-col>
          <el-col :span="20">
            <el-input
              v-model="form.remark"
              placeholder="请输入..."
              size="small"
            ></el-input>
          </el-col>
        </el-row>
        <el-row class="modal-content" :gutter="16">
          <el-col :span="4">
            <p class="modal-label-detail">初始密码</p>
          </el-col>
          <el-col :span="20">
            <el-input
              v-model="form.remark"
              placeholder="请输入..."
              size="small"
            ></el-input>
          </el-col>
        </el-row>
        <el-row class="modal-content" :gutter="16">
          <el-col :span="4">
            <p class="modal-label-detail">账号权限</p>
          </el-col>
          <el-col :span="20">
            <el-select v-model="form.class" placeholder="请选择" size="small">
              <el-option value="撒钱活动">撒钱活动</el-option>
              <el-option value="VIP活动">VIP活动</el-option>
            </el-select>
          </el-col>
        </el-row>
        <div slot="footer" class="modal-footer">
          <el-button
            type="primary"
            size="small"
            @click="onClickAddConfirm"
          >完成</el-button >
        </div>
      </div>
    </el-dialog>

    <!-- 点击重置密码 -->
    <el-dialog
      :visible.sync="showUpdatePassword"
    >
      <div class="modal-container">
        <div class="modal-label">
          <span>重置密码</span>
        </div>
        <el-row class="modal-content" :gutter="16">
          <el-col :span="6">
            <p class="modal-label-detail">新密码</p>
          </el-col>
          <el-col :span="18">
            <el-input
              v-model="form.remark"
              placeholder="请输入..."
              size="small"
            ></el-input>
          </el-col>
        </el-row>
        <el-row class="modal-content" :gutter="16">
          <el-col :span="6">
            <p class="modal-label-detail">确认新密码</p>
          </el-col>
          <el-col :span="18">
            <el-input
              v-model="form.remark"
              placeholder="请输入..."
              size="small"
            ></el-input>
          </el-col>
        </el-row>
        <div slot="footer" class="modal-footer">
          <el-button type="primary" @click="onClickAddConfirm">完成</el-button>
        </div>
      </div>
    </el-dialog>
  </div>
</template>

<script>
export default {
  data () {
    return {
      isLoading: false,
      showEditModal: false,
      showAddModal: false,
      showUpdatePassword: false,
      authSelect: ['群管理', '订单管理', '标签中心', '广告位管理', '用户管理', '报表管理', '账号管理'],
      totalPageCount: 10,
      form: {
        id: '',
        remark: '',
        roleName: '',
        gmtCreate: '',
        menuIds: [],
        pageIndex: 1,
        pageSize: 10,
      },
      add: {
        roleName: '',
        remark: '',
        menuIds: '',
        menuIds: []
      },
      columns7: [
        {
          title: '序号',
          type: 'index',
          align: 'center'
        },
        {
          title: '登录名',
          key: 'roleName',
          align: 'center'
        },
        {
          title: '权限',
          key: 'gmtCreate',
          align: 'center'
        },
        {
          title: '账号名称',
          key: 'remark',
          align: 'center'
        },
        {
          title: '创建时间',
          key: 'remark',
          align: 'center'
        },
        {
          title: '最后登录时间',
          key: 'remark',
          align: 'center'
        },
        {
          title: '操作',
          key: 'action',
          width: 300,
          align: 'center',
          render: (h, params) => {
            return h('div', [
              h('Button', {
                props: {
                  type: 'primary',
                  size: 'small'
                },
                style: {
                  marginRight: '5px',
                  width: '70px'
                },
                on: {
                  click: () => {
                    this.check(params.index)
                  }
                }
              }, '编辑'),
              h('Button', {
                props: {
                  type: 'error',
                  size: 'small'
                },
                style: {
                  marginRight: '5px',
                  width: '70px'
                },
                on: {
                  click: () => {
                    this.remove(params.index)
                  }
                }
              }, '删除'),
              h('Button', {
                props: {
                  type: 'primary',
                  size: 'small'
                },
                style: {
                  marginRight: '5px',
                  width: '70px'
                },
                on: {
                  click: () => {
                    this.updatePassword(params.index)
                  }
                }
              }, '重置密码')
            ]);
          }
        }
      ],
      tableData: [{
        roleName: '管理员'
      }]
    }
  },
  mounted() {
    // 获取所有菜单及id
    this.getAllMenusData()
    // 获取表格数据
    this.getTableData()
  },
  methods: {
    onClickAddAccount() {
      this.showAddModal = true
    },
    onClickEditConfirm() {
      //  点击修改
    },
    onClickAddConfirm() {
      //  点击添加确认按钮

    },
    check(index) {

    },
    remove(index) {
      this.$confirm('确定删除？', '确定删除？', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {

      }).catch(() => {

      });
    },
    resetPassword() {
      // 点击修改密码
      this.showUpdatePassword = true
    },
    getTableData(index) {

    },
    getAllMenusData() {

    }
  }
}
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped>
.pull-right {
  float: right;
}
.group-top {
  display: flex;
  align-items: flex-end;
  margin-bottom: 20px;
}
.group-right {
  display: flex;
  justify-content: flex-end;
}
.input-item button {
  color: #fff;
}
.table-container-page {
  text-align: center;
  margin-top: 20px;
}
.modal-content {
  margin-top: 15px;
}
.modal-label {
  display: table;
  white-space: nowrap;
  background: 0 0;
  font-weight: 500;
  color: #17233d;
  font-size: 16px;
  margin: 16px 0;
}
.modal-label span {
  font-size: 16px;
  display: inline-block;
  padding: 0 10px;
}
.modal-label:after {
  content: '';
  top: 50%;
  width: 95%;
  display: table-cell;
  position: relative;
  border-top: 1px solid #e8eaec;
  transform: translateY(50%);
}
.modal-label:before {
  content: '';
  top: 50%;
  width: 5%;
  display: table-cell;
  position: relative;
  border-top: 1px solid #e8eaec;
  transform: translateY(50%);
}
.modal-label-detail {
  text-align: right;
  line-height: 32px;
}
.modal-input {
  width: 100%;
}
.modal-footer {
  text-align: center;
  margin-top: 15px;
}
.modal-footer button {
  color: #fff;
  width: 100px;
}
.madal-radio-group {

}
.madal-radio {
  margin: 10px;
}
</style>
